include $(GNUSTEP_MAKEFILES)/common.make MODULE_NAME = nicola nicola_OBJC_FILES = file.m include $(GNUSTEP_MAKEFILES)/apache.makeThis is a plain makefile for an apache module whose source code is composed of a single plain file file.m. If you want to use more objective-C or C source files, you list them in the OBJC_FILES and C_FILES variables, as usual in GNUstep makefiles.
Here is a trivial example of such a file.m:
#include "httpd.h" #include "http_config.h" #include "http_protocol.h" #include "ap_config.h" #include <Foundation/Foundation.h> static int my_handler (request_rec *r) { NSString *string; NSString *name; CREATE_AUTORELEASE_POOL (arp); r->content_type = "text/html"; ap_send_http_header (r); name = [[NSProcessInfo processInfo] processName]; string = [NSString stringWithFormat: @"Hi from GNUstep in process %@\n", name]; ap_rputs ([string cString], r); RELEASE (arp); return OK; } static const handler_rec my_handlers[] = { { "my-handler", my_handler }, { NULL, NULL } }; module MODULE_VAR_EXPORT nicola_module = { STANDARD_MODULE_STUFF, NULL, NULL, NULL, NULL, NULL, NULL, my_handlers, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };Please make sure you notice that the module struct of your module must be named like the MODULE_NAME used in the GNUmakefile, with _module appended. In the example, the MODULE_NAME is nicola, so the C struct is called nicola_module.
Typing make will compile the module. Only building dynamically loaded Apache modules is supported. apache.make needs to use the apxs executable to build the module, so you need to have the apache binary directory in your path. This usually is something like /usr/local/apache/bin. Otherwise, you can still compile it by setting the APXS environment variable to point to where your apxs executable is.