summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo <mokha@cisco.com>2016-06-23 17:25:01 -0400
committermo <mokha@cisco.com>2016-06-23 17:25:21 -0400
commit4c0e550705dd2baa57ceaebbfcfe7db93bfab488 (patch)
treef228363313e69f47534158252f8cb5fba9ea584d
parent1a3a1c61d96c7bc08c2e47db3b50cea1d573b9cc (diff)
finish lab07
-rw-r--r--lab07/Makefile12
-rw-r--r--lab07/Makefile.libuser3
-rw-r--r--lab07/libuser.c18
-rw-r--r--lab07/test2.c2
4 files changed, 26 insertions, 9 deletions
diff --git a/lab07/Makefile b/lab07/Makefile
index 9137600..762fbcc 100644
--- a/lab07/Makefile
+++ b/lab07/Makefile
@@ -3,22 +3,22 @@ CC=/home/student/crosstools/arm-2010.09/bin/arm-none-linux-gnueabi-gcc
all: install
# link .o's together with correct soname and real name
-libmy-utils.so.1.0 : test1.o test2.o test3.o
- $(CC)
+libmy-utils.so.1.1 : test1.o test2.o test3.o
+ $(CC) -o libmy-utils.so.1.1 test1.o test2.o test3.o -shared -Wl,-soname=libmy-utils.so.1
test1.o : test1.c # compile test1 w/ correct flags and output test1.o
- $(CC)
+ $(CC) -o test1.o -fPIC -c test1.c
test2.o : test2.c # compile test2 w/ correct flags and output test2.o
- $(CC)
+ $(CC) -o test2.o -fPIC -c test2.c
test3.o : test3.c # compile test3 w/ correct flags and output test3.o
- $(CC)
+ $(CC) -o test3.o -fPIC -c test3.c
clean:
rm -f *.o *.so.*
-install: libmy-utils.so.1.0
+install: libmy-utils.so.1.1
cp $< /home/student/targetfs/usr/local/lib
diff --git a/lab07/Makefile.libuser b/lab07/Makefile.libuser
index 713cc94..988d110 100644
--- a/lab07/Makefile.libuser
+++ b/lab07/Makefile.libuser
@@ -10,8 +10,7 @@ clean:
rm -f $(APP) $(DESTDIR)/$(APP)
$(APP): $(APP).c Makefile
- $(CC) -o $@ $< # add the lib search path and lib name
+ $(CC) -o $@ $< -L. -lmy-utils # add the lib search path and lib name
install: $(APP)
cp $< $(DESTDIR)
-
diff --git a/lab07/libuser.c b/lab07/libuser.c
new file mode 100644
index 0000000..2fecec3
--- /dev/null
+++ b/lab07/libuser.c
@@ -0,0 +1,18 @@
+#include "stdio.h"
+#include "stdlib.h"
+
+int main (int argc, char *argv[])
+{
+ int i = atoi(argv[1]);
+ int result = 0;
+
+ result = increment(i);
+ printf("%d\n", result);
+ result = decrement(i);
+ printf("%d\n", result);
+ result = mult2(i);
+ printf("%d\n", result);
+
+ return(0);
+}
+
diff --git a/lab07/test2.c b/lab07/test2.c
index 48e542d..7549f6a 100644
--- a/lab07/test2.c
+++ b/lab07/test2.c
@@ -1,4 +1,4 @@
int mult2 (int x)
{
- return(x*4);
+ return(x*2);
}