# Makefile for the sources of the l4util library

PKGDIR	?= ../..
L4DIR	?= $(PKGDIR)/../..

SYSTEMS	= x86 x86-l4v2 x86-l4x0

SRC_C_$(ARCH)	+= ARCH-$(ARCH)/reboot.c
SRC_S_$(ARCH)	+= ARCH-$(ARCH)/kip_area.S

ALL_SRC_C	= apic.c getopt.c getopt1.c getopt2.c micros2l4to.c \
		  perform.c queue.c rand.c rdtsc.c sleep.c spin.c thread.c \
		  wait_queue.c base64.c slmap.c kip.c reboot.c \
		  $(SRC_C_$(ARCH))

SRC_C_x86-l4v2	= $(ALL_SRC_C)
SRC_C_x86-l4x0	= $(ALL_SRC_C)
SRC_S_x86-l4v2	= $(SRC_S_$(ARCH))
SRC_S_x86-l4x0	= $(SRC_S_$(ARCH))
SRC_C_libparsecmdline.a	= parse_cmdline.c base64.c
SRC_C_libmain.a	= __main.c

TARGET		=
TARGET_x86	= libparsecmdline.a lib$(PKGNAME).a libmain.a
TARGET_x86-l4v2	= lib$(PKGNAME).a
TARGET_x86-l4x0	= lib$(PKGNAME).a
MODE		= sigma0

PRIVATE_INCDIR_perform.o = .
PRIVATE_INCDIR_perform.s.o = .
PRIVATE_INCDIR_perform.pr.o = .

include $(L4DIR)/mk/lib.mk

perform.o:	pmc_events.h
pmc_events.h: pmc_events.in
	@$(GEN_MESSAGE)
	$(VERBOSE)sort < $^ > $^.sorted || rm $^.sorted
	$(VERBOSE)echo "/* created automatically from $^, do not edit */" > $@
	$(VERBOSE)awk '/^[0-9a-fA-F][0-9a-fA-F].*/{print "{0x"toupper($$1)", \""$$2"\"},"}' < $^.sorted >> $@ || rm $@
	$(VERBOSE)rm $^.sorted

vpath pmc_events.in ..
