-.PHONY: clean all
-MARTE_PATH=$(HOME)/marte
-CC=mgcc
-CFLAGS= -DMARTE_OS -g -Wall -I../include -I../../frsh/include -L../lib
-OBJS=$(patsubst %.c,%.o,$(wildcard *.c))
-FOSA_HEADERS=$(wildcard ../include/*.h)
-FRSH_FOSA_HEADERS=$(wildcard ../../frsh/include/frsh_fosa*.h)
-
-all: libfosa
-
-libfosa: $(OBJS) $(FOSA_HEADERS) $(FRSH_FOSA_HEADERS)
- @exec echo -en "\n>> Generating libfosa.a: ";
- @$(AR) -rc ../lib/libfosa.a $(OBJS)
- @exec echo " [OK]"
-
-%.o: %.c
- @exec echo -en "\n>> Compiling $<: ";
- @$(CC) -c $(CFLAGS) $< 1> /dev/null
- @exec echo -n " [OK]"
-
-test_fosa: libfosa
- @exec echo -en "\n>> Compiling and Linking test_fosa.c: ";
- @$(CC) $(CFLAGS) -lfosa test_fosa.c 1> /dev/null
- @exec echo " [OK]"
-
-test_fosa_ads: libfosa $(MARTE_PATH)/misc/load.o
- @exec echo -en "\n>> Compiling and Linking test_fosa_ads.c: ";
- @$(CC) $(CFLAGS) -lfosa test_fosa_ads.c $(MARTE_PATH)/misc/load.o 1> /dev/null
- @exec echo " [OK]"
-
-$(MARTE_PATH)/misc/load.o: $(MARTE_PATH)/misc/load.c
- @mgcc $(CFLAGS) -c -o $(MARTE_PATH)/misc/load.o $(MARTE_PATH)/misc/load.c 1> /dev/null
-
-clean:
- @exec echo -e "\n>> Cleaning up FOSA: ";
- @find \( -name '*.[oa]' -or -name '*~*' -or -name 'mprogram*' \) -print -delete
- @rm -f ../lib/libfosa.a
- @exec echo " [OK]"
+
+##
+## Makefile for FSF/FRSH C library
+## by Miguel Telleria de Esteban
+## Univ. de Cantabria
+## telleriam@unican.es
+##
+## --------------------------------------------
+
+
+# Here we define FRSHPATH, IPATH, OBJOPT, LPATH, EXTRALIBS, CFLAGS, LDFLAGS
+
+PLATFORM = MARTE_OS
+
+include ../../frsh/frsh_rules.mk
+
+# List of files #
+#################
+NAME = libfosa_marte.a
+
+SRC = fosa_clocks_and_timers.c fosa_threads_and_signals.c frsh_fosa.c fosa_mutexes_and_condvars.c \
+ fosa_app_def_sched.c
+
+PUBLIC_H_FOSA = fosa_app_def_sched.h fosa.h fosa_opaque_types.h fosa_clocks_and_timers.h \
+ fosa_configuration_parameters.h fosa_mutexes_and_condvars.h fosa_threads_and_signals.h \
+ fosa_types.h
+
+PUBLIC_H_FRSH_FOSA = frsh_fosa.h frsh_fosa_opaque.h
+
+# PRIVATE_H =
+
+OBJS = $(SRC:.c=.o)
+PUBLIC_H_LOCATIONS = $(addprefix $(FOSAPATH)/include/, $(PUBLIC_H_FOSA) ) $(addprefix $(FRSHPATH)/include, $(PUBLIC_H_FRSH_FOSA) )
+
+# Library and linking rules #
+##############################
+
+all: ../lib/$(NAME)
+
+../lib/$(NAME): $(OBJS)
+# $@ represents the target (in this case ../lib/$(NAME) )
+ $(AR) -rc $@ $(OBJS)
+
+
+mprogram-test: test_fosa.o ../lib/$(NAME)
+ $(CC) -o $@ -lfosa_marte $(LDFLAGS) $<
+
+
+
+# Compilation rule: For simplicity we make all sources #
+# depend on all header files. #
+#########################################################
+%.o: %.c $(PUBLIC_H_FILE_LOCATIONS) $(PRIVATE_H)
+# $< represents the first prerequisite (in this case %.c)
+ $(CC) $(CFLAGS) $(SRC_IPATH) -c $<
+
+# Clean up #
+############
+clean: lib-uninstall
+ rm -f $(OBJS) *~ sizes.o mprogram-sizes
+
+lib-uninstall:
+ rm -f ../lib/$(NAME)
+
+
+.PHONY: lib-uninstall clean sizes
+