module.mk 2.03 KB
Newer Older
albert's avatar
albert committed
1
# This file gets included into the main Makefile, in the top directory.
albert's avatar
albert committed
2

albert's avatar
albert committed
3
# for lib$(NAME).so and /usr/include/($NAME) and such
albert's avatar
albert committed
4
NAME      :=  proc
albert's avatar
albert committed
5

albert's avatar
albert committed
6
SHARED := 1
albert's avatar
albert committed
7

albert's avatar
albert committed
8
SONAME    :=  lib$(NAME).so.$(LIBVERSION)
albert's avatar
albert committed
9

albert's avatar
albert committed
10 11
#ALL        += proc/lib$(NAME).a
#INSTALL    += $(usr/lib)/lib$(NAME).a # plus $(usr/include)$(NAME) gunk
albert's avatar
albert committed
12
LIB_CFLAGS := $(CFLAGS)
albert's avatar
albert committed
13

albert's avatar
albert committed
14 15 16 17
ifeq ($(SHARED),1)
ALL        += proc/$(SONAME)
INSTALL    += $(lib)/$(SONAME)
LIB_CFLAGS += -fpic
albert's avatar
albert committed
18 19 20
LIBPROC    := proc/$(SONAME)
else
LIBPROC    := proc/lib$(NAME).a
albert's avatar
albert committed
21
endif
albert's avatar
albert committed
22

albert's avatar
albert committed
23 24 25
LIBSRC :=  $(wildcard proc/*.c)
LIBHDR :=  $(wildcard proc/*.h)
LIBOBJ :=  $(LIBSRC:.c=.o)
albert's avatar
albert committed
26

albert's avatar
albert committed
27 28 29 30 31

LIB_X := COPYING Makefile.noam module.mk
TARFILES += $(LIBSRC) $(LIBHDR) $(addprefix proc/,$(LIB_X))


albert's avatar
albert committed
32 33 34
# Clean away all output files, .depend, and symlinks.
# Use wildcards in case the version has changed.
CLEAN += proc/.depend proc/lib*.so* proc/lib*.a $(LIBOBJ)
albert's avatar
albert committed
35
DIRS  += proc/
albert's avatar
albert committed
36

albert's avatar
albert committed
37 38
#proc/lib$(NAME).a: $(LIBOBJ)
#	$(AR) rcs $@ $^
albert's avatar
albert committed
39

albert's avatar
albert committed
40 41 42
proc/$(SONAME): $(LIBOBJ)
	$(CC) -shared -Wl,-soname,$(SONAME) -o $@ $^ -lc
	cd proc && $(ln-sf) $(SONAME) lib$(NAME).so
albert's avatar
albert committed
43 44


albert's avatar
albert committed
45 46 47
# AUTOMATIC DEPENDENCY GENERATION -- GCC AND GNUMAKE DEPENDENT
proc/.depend: $(LIBSRC) $(LIBHDR)
	$(strip $(CC) $(LIB_CFLAGS) -MM -MG $(LIBSRC) > $@)
albert's avatar
albert committed
48 49

ifneq ($(MAKECMDGOALS),clean)
albert's avatar
albert committed
50
ifneq ($(MAKECMDGOALS),tar)
albert's avatar
albert committed
51
-include proc/.depend
albert's avatar
albert committed
52
endif
albert's avatar
albert committed
53
endif
albert's avatar
albert committed
54 55


albert's avatar
albert committed
56 57 58 59
$(lib)/$(SONAME) : proc/$(SONAME)
	$(install) --mode a=rx --strip $< $@
	cd $(lib) && $(ln-sf) $(SONAME) lib$(NAME).so
	$(ldconfig)
albert's avatar
albert committed
60

albert's avatar
albert committed
61 62
#$(usr/lib)/lib$(NAME).a : proc/lib$(NAME).a
#	$(install) --mode a=r --strip $< $@
albert's avatar
albert committed
63

albert's avatar
albert committed
64 65 66
# Junk anyway... supposed to go in /usr/include/$(NAME)
#$(HDRFILES) ??? : $(addprefix proc/,$(HDRFILES)) ???
#	$(install) --mode a=r $< $@
albert's avatar
albert committed
67 68 69 70


# CUSTOM c -> o rule so that command-line has minimal whitespace
%.o : %.c
albert's avatar
albert committed
71
	$(strip $(CC) $(LIB_CFLAGS) -c $<)
albert's avatar
albert committed
72 73


albert's avatar
albert committed
74
proc/version.o:	proc/version.c proc/version.h
albert's avatar
albert committed
75
ifdef MINORVERSION
albert's avatar
albert committed
76
	$(strip $(CC) $(LIB_CFLAGS) -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -DMINORVERSION=\"$(MINORVERSION)\" -c -o $@ $<)
albert's avatar
albert committed
77
else
albert's avatar
albert committed
78
	$(strip $(CC) $(LIB_CFLAGS) -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -c -o $@ $<)
albert's avatar
albert committed
79
endif