put /local/csch/root {../..}
put /local/csch/CFLAGS {-I.. }
put /local/csch/DEPCFLAGS /local/csch/CFLAGS
put /local/rnd/DEPDEPS {}
put /local/rnd/DEPCFLAGS {}

include {template/cc.tmpasm}
include [@@/local/csch/librnd_template@/debug.tmpasm@]


put /local/csch/OBJS [@
 abstract.o
 actions_csch.o
 attrib.o
 concrete.o
 cnc_any_obj.o
 cnc_arc.o
 cnc_bitmap.o
 cnc_conn.o
 cnc_grp.o
 cnc_line.o
 cnc_obj.o
 cnc_pen.o
 cnc_poly.o
 cnc_text.o
 cnc_text_dyn.o
 csch_printf.o
 compile.o
 drc.o
 engine.o
 event.o
 extobj.o
 hierarchy.o
 htPo.o
 htepu.o
 integrity.o
 intersect.o
 libcschem.o
 non_graphical.o
 oidpath.o
 op_common.o
 operation.o
 plug_io.o
 plug_library.o
 project.o
 project_act.o
 project_p4.o
 rtree.o
 triangle.o
 search.o
 undo.o
 util_abst.o
 util_compile.o
 util_endpoint.o
 util_export.o
 util_grp.o
 util_lib_fs.o
 util_loclib.o
 util_parse.o
 util_project.o
 util_wirenet.o
 vtcoutline.o
 vtoid.o
 vtoidpath.o
@]

uniq /local/csch/OBJS

put /local/csch/LIBS_3RD [@
	$(ROOT)/src_3rd/libminuid/libminuid.a
	$(ROOT)/src_3rd/load_cache/load_cache.o
@]
uniq /local/csch/LIBS_3RD

put /local/csch/DEPDEPS {}

### Makefile ###

print [@
ROOT=@/local/csch/root@
include $(ROOT)/Makefile.conf
include $(LIBRND_MAK)

CC=@cc/cc@
CFLAGS=@/local/csch/CFLAGS@ @/local/csch/c89flags@ @?/local/rnd/CFLAGS@ $(CFLAGS_LIBRND) @?/local/csch/librnd_extra_inc@
C89FLAGS=$(CFLAGS)
LDFLAGS=@/local/csch/LDFLAGS@ @?/local/rnd/LDFLAGS@ $(LDFLAGS_LIBRND) @?/local/csch/librnd_extra_ldf@
OBJS = @/local/csch/OBJS@
LIBRND_LIBDIR=$(LIBRND_PREFIX)/$(LIBRND_LIBARCHDIR)/librnd4
PLUGDIR=$(ROOT)/src/plugins

LIBMINUID_CFLAGS=@/local/csch/CFLAGS@  @?/local/rnd/CFLAGS@
LIBMINUID_LDFLAGS=@/local/csch/LDFLAGS@ @?/local/rnd/LDFLAGS@

LIBA=libcschem.a
CLEAN_FILES = $(LIBA)

all:
	$(MAKE) revcheck
	$(MAKE) all_lib

revcheck:
	cd $(ROOT)/scconfig && ./revtest Rev.stamp < Rev.tab

all_lib: $(LIBA)

$(LIBA): $(OBJS) @/local/csch/LIBS_3RD@
	ar rvu $(LIBA) $(OBJS)

$(ROOT)/src_3rd/libminuid/libminuid.a $(ROOT)/src_3rd/libminuid/minuid: $(ROOT)/src_3rd/libminuid/libminuid.h $(ROOT)/src_3rd/libminuid/libminuid.c
	cd $(ROOT)/src_3rd/libminuid && $(MAKE) CC="$(CC)" LIBMINUID_CFLAGS="$(LIBMINUID_CFLAGS)" LIBMINUID_LDFLAGS="$(LIBMINUID_LDFLAGS)"

buildin.c: $(PLUGDIR)/.builtin.pups $(PUPLUG)
	cd $(PLUGDIR) && $(PUPLUG) buildin.c "-" < $(PLUGDIR)/.builtin.pups > $(ROOT)/src/libcschem/buildin.c

buildin.h: $(PLUGDIR)/.builtin.pups $(PUPLUG)
	$(PUPLUG) buildin.h > buildin.h

clean:
	-rm $(LIBA) $(OBJS)

distclean: clean
	-rm config.h config.sh buildin.h Makefile

@]

put /local/comp/OBJS_C89 /local/csch/OBJS
put /local/comp/C89FLAGS {$(C89FLAGS)}
include [@@/local/csch/librnd_template@/compile.tmpasm@]


put /local/dep/OUTFN {../src/libcschem/Makefile.depgen}
put /local/dep/SRCS /local/csch/OBJS
put /local/dep/CFLAGS /local/csch/CFLAGS
gsub /local/dep/SRCS {.o } {.c }
include [@@/local/csch/librnd_template@/cdep.tmpasm@]

redir {../src/libcschem/Makefile.objs}
put /local/csch/o /local/csch/OBJS
sub  /local/csch/o {[ ]*$} {}
sub  /local/csch/o {^[ ]*} {}
gsub /local/csch/o { } { $(LIBCSCHEM)/}
print [@
LIBCSCHEM_OBJS=$(LIBCSCHEM)/@/local/csch/o@
@]
