1# Compiler/Linker/dynamic linker 2CC = gcc 3LD = gcc 4 5# flags to compile object files that can be used in a dynamic library 6CFLAGS = -fPIC -Wall -g -c -O2 -fno-strict-aliasing -pipe -Wall -std=c99 -D'CSOCKS_CONF="/usr/local/etc/csocks.conf"' 7# on some platforms, use '-fpic' instead. 8 9# Flags to create a dynamic library. 10DYNLINKFLAGS = -shared -nostdlib 11# on some platforms, use '-G' instead. 12 13# files removal 14RM = /bin/rm -f 15 16# library's object files. 17LIB_OBJS = csocks.o 18 19# library's archive file 20LIB_FILE = libcsocks.so.1 21 22# library to use when linking the main program 23# the '-L.' option is used to tell the compiler to look for libraries 24# in the current directory, as well as the normal system library locations. 25LIBS = -L. -lutil 26 27 28# top-level rule 29all: $(LIB_FILE) 30 31# create our library 32$(LIB_FILE): $(LIB_OBJS) 33 $(LD) $(DYNLINKFLAGS) $(LIB_OBJS) -o $(LIB_FILE) 34 35# compile C source files into object files. 36%.o: %.c 37 $(CC) $(CFLAGS) -c $< 38 39 40# clean everything 41clean: 42 $(RM) $(LIB_OBJS) $(LIB_FILE) *.so 43 44# clean the program and its object files, don't touch the library. 45cleanprog: 46 $(RM) 47 48# clean the library and its object files only 49cleanlib: 50 $(RM) $(LIB_OBJS) $(LIB_FILE) 51 52# clean the library's object files only 53cleanlibobjs: 54 $(RM) $(LIB_OBJS) 55 56