Script started on Wed Nov 13 13:08:25 2024 mweeks@air:unix_ch12$ ls make_project/ Makefile db.o supps.c README.txt example_makefile supps.h db parts.c supps.o db.c parts.h db.h parts.o mweeks@air:unix_ch12$ # with tar, cvf and xvf are important to know mweeks@air:unix_ch12$ # cvf creates verbose file mweeks@air:unix_ch12$ # xvf extract verbose file mweeks@air:unix_ch12$ tar cvf make_project.tar make_project/ a make_project a make_project/parts.c a make_project/db.h a make_project/Makefile a make_project/db.o a make_project/supps.c a make_project/parts.o a make_project/parts.h a make_project/db a make_project/README.txt a make_project/example_makefile a make_project/db.c a make_project/supps.o a make_project/supps.h mweeks@air:unix_ch12$ ls -l make_project.tar -rw-r--r-- 1 mweeks staff 25600 Nov 13 13:12 make_project.tar mweeks@air:unix_ch12$ sftp snowball.cs.gsu.edu mweeks@snowball.cs.gsu.edu's password: Connected to snowball.cs.gsu.edu. sftp> quit mweeks@air:unix_ch12$ gzip make_project.tar mweeks@air:unix_ch12$ ls -l make_project.tar ls: make_project.tar: No such file or directory mweeks@air:unix_ch12$ ls -l make_project.tar* -rw-r--r-- 1 mweeks staff 3074 Nov 13 13:12 make_project.tar.gz mweeks@air:unix_ch12$ sftp snowball.cs.gsu.edu mweeks@snowball.cs.gsu.edu's password: Permission denied, please try again. mweeks@snowball.cs.gsu.edu's password: Connected to snowball.cs.gsu.edu. sftp> put make_project.tar.gz Uploading make_project.tar.gz to /home/mweeks/make_project.tar.gz make_project.tar.gz 100% 3074 15.8KB/s 00:00 sftp> quit mweeks@air:unix_ch12$ ssh snowball.cs.gsu.edu mweeks@snowball.cs.gsu.edu's password: Last failed login: Wed Nov 13 13:14:37 EST 2024 from 131.96.221.133 on ssh:notty There was 1 failed login attempt since the last successful login. Last login: Mon Nov 11 14:01:53 2024 from 131.96.222.91 + | GSU Computer Science | Instructional Server | SNOWBALL.cs.gsu.edu + [mweeks@gsuad.gsu.edu@snowball ~]$ ls -l make_project.tar.gz -rw-r--r--. 1 mweeks@gsuad.gsu.edu mweeks@gsuad.gsu.edu 3074 Nov 13 13:15 make_project.tar.gz [mweeks@gsuad.gsu.edu@snowball ~]$ gunzip make_project.tar.gz [mweeks@gsuad.gsu.edu@snowball ~]$ ls -l make_project.ta* -rw-r--r--. 1 mweeks@gsuad.gsu.edu mweeks@gsuad.gsu.edu 25600 Nov 13 13:15 make_project.tar [mweeks@gsuad.gsu.edu@snowball ~]$ tar xvf make_project.tar make_project/ make_project/parts.c make_project/db.h make_project/Makefile make_project/db.o make_project/supps.c make_project/parts.o make_project/parts.h make_project/db make_project/README.txt make_project/example_makefile make_project/db.c make_project/supps.o make_project/supps.h [mweeks@gsuad.gsu.edu@snowball ~]$ rm make_project.tar [mweeks@gsuad.gsu.edu@snowball ~]$ cd make_project/ [mweeks@gsuad.gsu.edu@snowball make_project]$ ls -l total 60 -rwxr-xr-x. 1 mweeks@gsuad.gsu.edu mweeks@gsuad.gsu.edu 8624 Aug 5 23:48 db -rw-r--r--. 1 mweeks@gsuad.gsu.edu mweeks@gsuad.gsu.edu 293 Aug 5 23:48 db.c -rw-r--r--. 1 mweeks@gsuad.gsu.edu mweeks@gsuad.gsu.edu 59 Aug 5 23:48 db.h -rw-r--r--. 1 mweeks@gsuad.gsu.edu mweeks@gsuad.gsu.edu 1204 Aug 5 23:48 db.o -rw-r--r--. 1 mweeks@gsuad.gsu.edu mweeks@gsuad.gsu.edu 200 Aug 5 23:48 example_makefile -rw-r--r--. 1 mweeks@gsuad.gsu.edu mweeks@gsuad.gsu.edu 280 Aug 5 23:48 Makefile -rw-r--r--. 1 mweeks@gsuad.gsu.edu mweeks@gsuad.gsu.edu 245 Aug 5 23:48 parts.c -rw-r--r--. 1 mweeks@gsuad.gsu.edu mweeks@gsuad.gsu.edu 137 Aug 5 23:48 parts.h -rw-r--r--. 1 mweeks@gsuad.gsu.edu mweeks@gsuad.gsu.edu 980 Aug 5 23:48 parts.o -rw-r--r--. 1 mweeks@gsuad.gsu.edu mweeks@gsuad.gsu.edu 58 Aug 5 23:48 README.txt -rw-r--r--. 1 mweeks@gsuad.gsu.edu mweeks@gsuad.gsu.edu 747 Aug 5 23:48 supps.c -rw-r--r--. 1 mweeks@gsuad.gsu.edu mweeks@gsuad.gsu.edu 75 Aug 5 23:48 supps.h -rw-r--r--. 1 mweeks@gsuad.gsu.edu mweeks@gsuad.gsu.edu 708 Aug 5 23:48 supps.o [mweeks@gsuad.gsu.edu@snowball make_project]$ cat example_makefile db: db.o supps.o parts.o gcc db.o supps.o parts.o -o db db.o: db.c db.h supps.h parts.h gcc -c db.c supps.o: supps.c supps.h gcc -c supps.c parts.o: parts.c parts.h gcc -c parts.c [mweeks@gsuad.gsu.edu@snowball make_project]$ ls *c db.c parts.c supps.c [mweeks@gsuad.gsu.edu@snowball make_project]$ cat db.c #include "db.h" int main() { int i; printf("The array has %d values\n", array_length()); array_init(a); i = array_length() - 2; array_set(i, 5); if (is_prime(a[i])) printf("Value %d is prime.\n", a[i]); else printf("Value %d is not prime.\n", a[i]); return 0; } [mweeks@gsuad.gsu.edu@snowball make_project]$ cat db.h #include #include "parts.h" #include "supps.h" [mweeks@gsuad.gsu.edu@snowball make_project]$ cat supps.h #include #include #define N 10 bool is_prime(int); [mweeks@gsuad.gsu.edu@snowball make_project]$ cat supps.c /********************************************************* * From C PROGRAMMING: A MODERN APPROACH, by K. N. King * * Copyright (c) 1996 W. W. Norton & Company, Inc. * * All rights reserved. * * This program may be freely distributed for class use, * * provided that this copyright notice is retained. * *********************************************************/ /* prime.c (Chapter 9, page 162) */ /* Tests whether a number is prime */ // altered a bit to use as an example for "make" #include "supps.h" bool is_prime(int n) { int divisor; if (n <= 1) return false; for (divisor = 2; divisor * divisor <= n; divisor++) if (n % divisor == 0) return false; return true; } [mweeks@gsuad.gsu.edu@snowball make_project]$ cat parts.h #include #include #define N 10 int a[N]; void array_set(int, int); int array_length(); void array_init(int *); [mweeks@gsuad.gsu.edu@snowball make_project]$ cat parts.c #include "parts.h" void array_init(int *p) { int i; for (i=0; i= 0) && (index < N)) a[index] = value; } [mweeks@gsuad.gsu.edu@snowball make_project]$ more example_makefile db: db.o supps.o parts.o gcc db.o supps.o parts.o -o db db.o: db.c db.h supps.h parts.h gcc -c db.c supps.o: supps.c supps.h gcc -c supps.c parts.o: parts.c parts.h gcc -c parts.c [mweeks@gsuad.gsu.edu@snowball make_project]$ [mweeks@gsuad.gsu.edu@snowball make_project]$ make make: `db' is up to date. [mweeks@gsuad.gsu.edu@snowball make_project]$ rm supps.o [mweeks@gsuad.gsu.edu@snowball make_project]$ make echo "make supps.o" ; gcc -c supps.c make supps.o echo "make db" ; gcc db.o supps.o parts.o -o db make db db.o: file not recognized: File format not recognized collect2: error: ld returned 1 exit status make: *** [db] Error 1 [mweeks@gsuad.gsu.edu@snowball make_project]$ cat Makefile db: db.o supps.o parts.o echo "make db" ; gcc db.o supps.o parts.o -o db db.o: db.c db.h supps.h parts.h echo "make db.o" ; gcc -c db.c supps.o: supps.c supps.h echo "make supps.o" ; gcc -c supps.c parts.o: parts.c parts.h echo "make parts.o" ; gcc -c parts.c [mweeks@gsuad.gsu.edu@snowball make_project]$ ls db.c db.o Makefile parts.h README.txt supps.h db.h example_makefile parts.c parts.o supps.c supps.o [mweeks@gsuad.gsu.edu@snowball make_project]$ cat README.txt make -f example_makefile or just "make" to run Makefile [mweeks@gsuad.gsu.edu@snowball make_project]$ make -f example_makefile gcc db.o supps.o parts.o -o db db.o: file not recognized: File format not recognized collect2: error: ld returned 1 exit status make: *** [db] Error 1 [mweeks@gsuad.gsu.edu@snowball make_project]$ rm *.o [mweeks@gsuad.gsu.edu@snowball make_project]$ make -f example_makefile gcc -c db.c gcc -c supps.c gcc -c parts.c gcc db.o supps.o parts.o -o db [mweeks@gsuad.gsu.edu@snowball make_project]$ ./db The array has 10 values Value 5 is prime. [mweeks@gsuad.gsu.edu@snowball make_project]$ touch supps.c [mweeks@gsuad.gsu.edu@snowball make_project]$ ls -l supp* -rw-r--r--. 1 mweeks@gsuad.gsu.edu mweeks@gsuad.gsu.edu 747 Nov 13 13:29 supps.c -rw-r--r--. 1 mweeks@gsuad.gsu.edu mweeks@gsuad.gsu.edu 75 Aug 5 23:48 supps.h -rw-rw-r--. 1 mweeks@gsuad.gsu.edu mweeks@gsuad.gsu.edu 1296 Nov 13 13:29 supps.o [mweeks@gsuad.gsu.edu@snowball make_project]$ vi parts.h [mweeks@gsuad.gsu.edu@snowball make_project]$ make -f example_makefile gcc -c db.c gcc -c supps.c gcc -c parts.c gcc db.o supps.o parts.o -o db [mweeks@gsuad.gsu.edu@snowball make_project]$ ls -l db -rwxrwxr-x. 1 mweeks@gsuad.gsu.edu mweeks@gsuad.gsu.edu 8584 Nov 13 13:30 db [mweeks@gsuad.gsu.edu@snowball make_project]$ ./db The array has 10 values Value 5 is prime. [mweeks@gsuad.gsu.edu@snowball make_project]$ vi example_makefile [mweeks@gsuad.gsu.edu@snowball make_project]$ # in a makefile [mweeks@gsuad.gsu.edu@snowball make_project]$ # targetlist : target files [mweeks@gsuad.gsu.edu@snowball make_project]$ # dependecnylist : list of things that, if they change, we do the commands [mweeks@gsuad.gsu.edu@snowball make_project]$ # [TAB] commandlist: commands to make the target [mweeks@gsuad.gsu.edu@snowball make_project]$ exit logout Connection to snowball.cs.gsu.edu closed. mweeks@air:unix_ch12$ exit exit Script done on Wed Nov 13 13:43:08 2024