Home | History | Annotate | Download | only in cs
      1 
      2 
      3 ifeq ($(NEOTONIC_ROOT),)
      4 NEOTONIC_ROOT = ..
      5 endif
      6 
      7 include $(NEOTONIC_ROOT)/rules.mk
      8 
      9 CS_LIB = $(LIB_DIR)libneo_cs.a
     10 CS_SRC = csparse.c
     11 CS_OBJ = $(CS_SRC:%.c=%.o)
     12 
     13 CSTEST_EXE = cstest
     14 CSTEST_SRC = cstest.c
     15 CSTEST_OBJ = $(CSTEST_SRC:%.c=%.o)
     16 
     17 CSR_EXE = cs
     18 CSR_SRC = cs.c
     19 CSR_OBJ = $(CSR_SRC:%.c=%.o)
     20 
     21 CSDUMP_EXE = csdump
     22 CSDUMP_SRC = csdump.c
     23 CSDUMP_OBJ = $(CSDUMP_SRC:%.c=%.o)
     24 
     25 LIBS += -lneo_cs -lneo_utl #  -lefence
     26 
     27 TARGETS = $(CS_LIB) $(CSTEST_EXE) $(CSR_EXE) test
     28 
     29 CS_TESTS = test.cs test2.cs test3.cs test4.cs test5.cs test6.cs test7.cs \
     30            test8.cs test9.cs test10.cs test11.cs test12.cs test13.cs \
     31 	   test14.cs test15.cs test16.cs test17.cs test18.cs test19.cs \
     32 	   test_var.cs test_paren.cs test_chuck.cs test_trak1.cs test_iter.cs \
     33 	   test_each_array.cs test_name.cs test_with.cs test_numbers.cs \
     34 	   test_splice.cs test_joo.cs test_first_last.cs test_abs_max_min.cs \
     35 	   test_comma.cs test_macro_set.cs test_func.cs test_escape.cs \
     36 	   test_uvar.cs test_crc.cs
     37 
     38 
     39 all: $(TARGETS)
     40 
     41 $(CS_LIB): $(CS_OBJ)
     42 	$(AR) $@ $(CS_OBJ)
     43 	$(RANLIB) $@
     44 
     45 $(CSTEST_EXE): $(CSTEST_OBJ) $(CS_LIB)
     46 	$(LD) $@ $(CSTEST_OBJ) $(LDFLAGS) $(LIBS) # -lefence
     47 
     48 $(CSR_EXE): $(CSR_OBJ) $(CS_LIB)
     49 	$(LD) $@ $(CSR_OBJ) $(LDFLAGS) $(LIBS) # -lefence
     50 
     51 $(CSDUMP_EXE): $(CSDUMP_OBJ) $(CS_LIB)
     52 	$(LD) $@ $(CSDUMP_OBJ) $(LDFLAGS) $(LIBS)
     53 
     54 ## BE VERY CAREFUL WHEN REGENERATING THESE
     55 gold: $(CSTEST_EXE)
     56 	@for test in $(CS_TESTS); do \
     57 		rm -f $$test.gold; \
     58 		./cstest test.hdf $$test > $$test.gold; \
     59 	done; \
     60 	./cstest test_tag.hdf test_tag.cs > test_tag.cs.gold
     61 	@echo "Generated Gold Files"
     62 
     63 test: $(CSTEST_EXE) $(CS_TESTS) 
     64 	@echo "Running cs regression tests"
     65 	@failed=0; \
     66 	for test in $(CS_TESTS); do \
     67 		rm -f $$test.out; \
     68 		./cstest test.hdf $$test > $$test.out 2>&1; \
     69 		diff $$test.out $$test.gold 2>&1 > /dev/null; \
     70 		return_code=$$?; \
     71 		if [ $$return_code -ne 0 ]; then \
     72 		  diff $$test.gold $$test.out > $$test.err; \
     73 		  echo "Failed Regression Test: $$test"; \
     74 		  echo "  See $$test.out and $$test.err"; \
     75 		  failed=1; \
     76 		fi; \
     77 	done; \
     78 	rm -f test_tag.cs.out; \
     79 	./cstest test_tag.hdf test_tag.cs> test_tag.cs.out 2>&1; \
     80 	diff test_tag.cs.out test_tag.cs.gold; \
     81 	return_code=$$?; \
     82 	if [ $$return_code -ne 0 ]; then \
     83 	  echo "Failed Regression Test: test_tag.cs"; \
     84 	  failed=1; \
     85 	fi; \
     86 	if [ $$failed -eq 1 ]; then \
     87 	  exit 1; \
     88 	fi;
     89 	@touch test
     90 	@echo "Passed"
     91 	
     92 install: all
     93 	$(NEOTONIC_ROOT)/mkinstalldirs $(DESTDIR)$(cs_includedir)/cs
     94 	$(INSTALL) -m 644 cs.h $(DESTDIR)$(cs_includedir)/cs
     95 	$(INSTALL) -m 644 $(CS_LIB) $(DESTDIR)$(libdir)
     96 	$(INSTALL) $(CSTEST_EXE) $(DESTDIR)$(bindir)
     97 	$(INSTALL) $(CSR_EXE) $(DESTDIR)$(bindir)
     98 
     99 clean:
    100 	$(RM) core *.o
    101 
    102 distclean:
    103 	$(RM) Makefile.depends $(TARGETS) core *.o *.out
    104