1 # This Makefile.common is used only in an nhc98 build of the libraries.
2 # It is included from each package's individual Makefile.nhc98.
3 # We assume the following definitions have already been made in
4 # the importing Makefile.
7 # SEARCH = e.g. -P../IO -P../PreludeIO -package base
8 # SRCS = all .hs .gc and .c files
10 # EXTRA_H_FLAGS = e.g. -prelude
11 # EXTRA_C_FLAGS = e.g. -I../Binary
12 include ../Makefile.inc
14 # nasty hack - replace flags for ghc, nhc98, with hbc specific ones
15 ifeq "hbc" "${BUILDCOMP}"
16 EXTRA_H_FLAGS := ${EXTRA_HBC_FLAGS}
19 DIRS = $(shell ${LOCAL}pkgdirlist ${THISPKG})
21 OBJDIR = ${BUILDDIR}/${OBJ}/libraries/${THISPKG}
22 OBJDIRS = $(patsubst %, ${OBJDIR}/%, ${DIRS})
23 FINALLIB = ${DST}/libHS${THISPKG}.$A
24 INCDIRS = ${INCDIR}/packages/${THISPKG} \
25 $(patsubst %, ${INCDIR}/packages/${THISPKG}/%, ${DIRS})
26 .SUFFIXES: .hi .hs .lhs .o .gc .c .hc .p.o .p.c .z.o .z.c .hsc
28 SRCS_HS = $(filter %.hs, ${SRCS})
29 SRCS_LHS = $(filter %.lhs,${SRCS})
30 SRCS_GC = $(filter %.gc, ${SRCS})
31 SRCS_HSC = $(filter %.hsc,${SRCS})
32 SRCS_C = $(filter %.c, ${SRCS})
33 SRCS_HASK= $(SRCS_HS) $(SRCS_LHS) $(SRCS_GC) $(SRCS_HSC)
35 OBJS_HS = $(patsubst %.hs, ${OBJDIR}/%.$O, ${SRCS_HS})
36 OBJS_LHS = $(patsubst %.lhs,${OBJDIR}/%.$O, ${SRCS_LHS})
37 OBJS_GC = $(patsubst %.gc, ${OBJDIR}/%.$O, ${SRCS_GC})
38 OBJS_HSC = $(patsubst %.hsc,${OBJDIR}/%.$O, ${SRCS_HSC})
39 OBJS_C = $(patsubst %.c, ${OBJDIR}/%.$O, ${SRCS_C})
40 OBJS_HASK= ${OBJS_HS} ${OBJS_LHS} ${OBJS_GC} ${OBJS_HSC}
41 OBJS = $(OBJS_HASK) $(OBJS_C)
43 CFILES_HS = $(patsubst %.hs, %.$C, ${SRCS_HS})
44 CFILES_LHS = $(patsubst %.lhs,%.$C, ${SRCS_LHS})
45 CFILES_GC = $(patsubst %.gc, %.$C, ${SRCS_GC})
46 CFILES_XS = $(patsubst %.gc, %_.$C, ${SRCS_GC}) \
47 $(patsubst %.gc, %_.hs, ${SRCS_GC})
48 CFILES_HSC = $(patsubst %.hsc,%.$C, ${SRCS_HSC})
49 CFILES_GEN = ${CFILES_HS} ${CFILES_LHS} ${CFILES_GC} ${CFILES_HSC}
51 ifeq "p" "${PROFILING}"
59 all: ${OBJDIR} ${OBJDIRS} ${INCDIRS} extra ${OBJS} ${FINALLIB}
61 cfiles: extracfiles ${CFILES_GEN}
63 fromC: ${OBJDIR} ${OBJS_C} ${OBJDIRS}
64 $(HC) -c -d $(OBJDIR) $(EXTRA_C_FLAGS) ${SEARCH} ${CFILES_GEN}
65 echo $(OBJS) | xargs ar cr ${FINALLIB}
66 objdir: ${OBJDIR} ${OBJDIRS} ${INCDIRS}
67 ${OBJDIR} ${OBJDIRS} ${INCDIRS}:
70 echo $(OBJS) | xargs ar cr $@
72 -rm -f $(patsubst %, %/*.hi, ${DIRS})
74 -rm -f ${CFILES_GEN} ${CFILES_XS}
76 -rm -f $(patsubst %, ${OBJDIR}/%/*.$O, ${DIRS})
77 -rm -f $(patsubst %.gc, %_.hs, $(filter %.gc, $(SRCS)))
78 -rm -f $(patsubst %.gc, %_.$C, $(filter %.gc, $(SRCS)))
81 # general build rules for making objects from Haskell files
82 $(OBJS_HASK): #$(OBJDIR) $(OBJDIRS) $(SRCS_HASK)
83 $(LOCAL)hmake -hc=$(HC) -hidir $(INCDIR)/packages/$(THISPKG) \
84 $(SEARCH) $(EXTRA_H_FLAGS) -d$(OBJDIR) \
86 ${OBJS_HS}: ${OBJDIR}/%.$O : %.hs
87 ${OBJS_LHS}: ${OBJDIR}/%.$O : %.lhs
88 ${OBJS_GC}: ${OBJDIR}/%.$O : %.gc
89 ${OBJS_HSC}: ${OBJDIR}/%.$O : %.hsc
91 # general build rule for making objects from C files
92 ${OBJS_C}: ${OBJDIR}/%.$O : cbits/%.c
93 $(CC) -c -I$(INCDIR) $(ENDIAN) $(filter -I%, ${SEARCH}) \
94 $(EXTRA_C_FLAGS) -o $@ $<
96 # general build rules for making bootstrap C files from Haskell files
98 $(LOCAL)hmake -hc=$(HC) -C -hidir $(INCDIR)/packages/$(THISPKG) \
99 $(SEARCH) $(EXTRA_H_FLAGS) \
101 ${CFILES_HS}: %.$C : %.hs
102 ${CFILES_LHS}: %.$C : %.lhs
103 ${CFILES_GC}: %.$C : %.gc
104 ${CFILES_HSC}: %.$C : %.hsc
106 # hack to get round mutual recursion between libraries
107 HIFILES = $(patsubst %.hs,../${THISLIB}/%.${HISUFFIX},$(filter %.hs, ${SRCS}))
108 ${HIFILES}: ../${THISLIB}/%.${HISUFFIX} : %.hs
109 $(HC) -c $(PART_FLAGS) -o /dev/null $<
111 # The importing Makefile may now define extra individual dependencies
113 # ${OBJDIR}/Function.$O: Function.hs ${OBJDIR}/Other.$O
115 # and C-files dependencies likewise
117 # AlignBin.c: BinHandle.c